/*
   Copyright 2009 Abdulla Abdurakhmanov (abdulla@latestbit.com)
   Original sources are available at www.latestbit.com

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */

package org.latestbit.smartobjects.network;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import org.latestbit.smartobjects.exceptions.IncorrectURIException;

/**
 * Managed client provides interface to all connectors for one logical endpoint
 * @author abdulla-a
 *
 */
public interface IManagedClient extends IManagedConnection {

	/**
	 * Starts all connectors
	 * @throws IncorrectURIException
	 * @throws IOException
	 */
	public abstract void start() throws IncorrectURIException, IOException;
	
	/**
	 * Starts all connectors and synchronous wait to connect one of connectors
	 * @param awaitConnectTime timeout
	 * @param awaitConnectTimeUnit timeout units
	 * @throws IncorrectURIException
	 * @throws IOException
	 * @throws InterruptedException
	 */
	public abstract void start(long awaitConnectTime, TimeUnit awaitConnectTimeUnit)
		throws IncorrectURIException, IOException, InterruptedException;

	/**
	 * Stops all connectors
	 */
	public abstract void stop();
	
	/**
	 * Sets endpoint location
	 * @param location endpoint location
	 * @param coordinator endpoint coordinator instance
	 * @throws IncorrectURIException
	 * @throws IOException
	 */
	public abstract void setEndpointLocation(IEndpointLocation location, IEndpointCoordinator coordinator) 
		throws IncorrectURIException, IOException;	
	
	public void destroy();
	
}